module Spydec
  class Website
    def initialize(page_url)
      @page_url = page_url
      @page = Nokogiri::HTML(open(@page_url))
    end
    
    def author
      @page.xpath("//meta[@name='author']/@content").text
    end
    
    def canonical
      @page.xpath("//link[@rel='canonical']/@href").text
    end
    
    def desc
      @page.xpath("//meta[@name='description']/@content").text
    end
    
    def keywords
      @page.xpath("//meta[@name='keywords']/@content").text.split(", ")
    end
    
    def title
      @page.xpath("//title").text
    end
    
    def all
      com_page = []
      com_page << author
      com_page << canonical
      com_page << desc
      com_page << keywords
      com_page << title
      com_page
    end
  end
end